package com.gjy.datetime.time;

import org.junit.jupiter.api.Test;

import java.text.SimpleDateFormat;
import java.time.Duration;
import java.time.LocalDateTime;
import java.time.Period;
import java.util.Date;

/**
 * @author 宫静雨
 * @version 1.0
 * @since 2023-03-31 11:09:14
 */
public class DurationTest {

    @Test
    public void test2() {
        Period period = Period.ofYears(2023);
        System.out.println("period = " + period);
        System.out.println("period.getDays() = " + period.getDays());
    }

    @Test
    public void test1() {
        Duration between = Duration.between(LocalDateTime.of(2023, 3, 30, 0, 0, 0),
                LocalDateTime.now());
        long l = between.toDays();
        System.out.println("l = " + l);
    }

    private static void parse(long millis) {
        String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
                .format(new Date(millis));
        System.out.println("format = " + format);
    }

}
